﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AnnotationViewModel.cs" company="Mar3ek">
//   http://mar3ek.wordpress.com
// </copyright>
// <summary>
//   Defines the AnnotationViewModel type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Mar3ek.ColorHatTimeTracker
{
    using System;
    using System.ComponentModel;
    using System.Runtime.CompilerServices;

    using Mar3ek.ColorHatTimeTracker.Annotations;

    /// <summary>
    /// The annotation view model.
    /// </summary>
    public class AnnotationViewModel : INotifyPropertyChanged
    {
        /// <summary>
        /// The annotation.
        /// </summary>
        private string annotation;

        /// <summary>
        /// The client.
        /// </summary>
        private string client;

        /// <summary>
        /// The service.
        /// </summary>
        private string service;

        /// <summary>
        /// The duration.
        /// </summary>
        private string duration;

        /// <summary>
        /// The segment start.
        /// </summary>
        private DateTime segmentStart;

        /// <summary>
        /// The segment end.
        /// </summary>
        private DateTime segmentEnd;

        /// <summary>
        /// The property changed event delegate.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Gets or sets the annotation.
        /// </summary>
        public string Annotation
        {
            get
            {
                return this.annotation;
            }

            set
            {
                if (value == this.annotation)
                {
                    return;
                }

                this.annotation = value;
                this.OnPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the client.
        /// </summary>
        public string Client
        {
            get
            {
                return this.client;
            }

            set
            {
                if (value == this.client)
                {
                    return;
                }

                this.client = value;
                this.OnPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the service.
        /// </summary>
        public string Service
        {
            get
            {
                return this.service;
            }

            set
            {
                if (value == this.service)
                {
                    return;
                }

                this.service = value;
                this.OnPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the duration.
        /// </summary>
        public string Duration
        {
            get
            {
                return this.duration;
            }

            set
            {
                if (value == this.duration)
                {
                    return;
                }

                this.duration = value;
                this.OnPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the segment start.
        /// </summary>
        public DateTime SegmentStart
        {
            get
            {
                return this.segmentStart;
            }

            set
            {
                if (value.Equals(this.segmentStart))
                {
                    return;
                }

                this.segmentStart = value;
                this.OnPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the segment end.
        /// </summary>
        public DateTime SegmentEnd
        {
            get
            {
                return this.segmentEnd;
            }

            set
            {
                if (value.Equals(this.segmentEnd))
                {
                    return;
                }

                this.segmentEnd = value;
                this.OnPropertyChanged();
            }
        }

        /// <summary>
        /// The property changed event invocator.
        /// </summary>
        /// <param name="propertyName">
        /// The property name.
        /// </param>
        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
